package cn.itcast.star.graph.core.service.impl;


import cn.itcast.star.graph.comfyui.client.pojo.ComfyuiModel;
import cn.itcast.star.graph.core.service.FreemarkerService;
import freemarker.template.Configuration;
import freemarker.template.Template;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.StringWriter;
import java.util.Map;


/**
 * @author Windows
 */
@Service
public class FreemarkerServiceImpl implements FreemarkerService {
    @Resource
    Configuration configuration;

    /**
     * 将ollama调用大模型翻译的英文写入模板数据中
     * @param model
     * @return
     * @throws Exception
     */
    @Override
    public String renderText2Image(ComfyuiModel model) throws Exception {
        Template template = configuration.getTemplate("t2i.ftlh");
        StringWriter temp = new StringWriter();
        template.process(Map.of("config",model), temp);
        return temp.toString();
    }
}
